package com.jzqf.harmonydemo.utils;

import java.util.Arrays;

public class ArrayUtil {

    /**
     * 判断值是否在数组范围内
     *
     * @param range 数组
     * @param value 待比较的值
     * @return true 在数组范围内
     */
    public static boolean contains(int[] range, int value) {
        Arrays.sort(range);
        return Arrays.binarySearch(range, value) > 0;
    }

    public static boolean contains(byte[] range, byte value) {
        Arrays.sort(range);
        return Arrays.binarySearch(range, value) > 0;
    }

    public static boolean contains(String[] range, String value) {
        Arrays.sort(range);
        return Arrays.binarySearch(range, value) > 0;
    }
}
